package de.measite.smack;

import com.novell.sasl.client.DigestMD5SaslClient;
import java.util.Map;
import org.apache.harmony.javax.security.auth.callback.CallbackHandler;
import org.apache.harmony.javax.security.sasl.SaslClient;
import org.apache.harmony.javax.security.sasl.SaslClientFactory;
import org.apache.harmony.javax.security.sasl.SaslException;
import org.apache.qpid.management.common.sasl.PlainSaslClient;

public class SaslClientFactory
  implements org.apache.harmony.javax.security.sasl.SaslClientFactory
{
  public SaslClient createSaslClient(String[] paramArrayOfString, String paramString1, String paramString2, String paramString3, Map<String, ?> paramMap, CallbackHandler paramCallbackHandler)
    throws SaslException
  {
    int i = paramArrayOfString.length;
    int j = 0;
    while (true)
    {
      Object localObject;
      if (j >= i)
        localObject = null;
      while (true)
      {
        String str;
        while (true)
        {
          return localObject;
          str = paramArrayOfString[j];
          if (!("PLAIN".equals(str)))
            break;
          localObject = new PlainSaslClient(paramString1, paramCallbackHandler);
        }
        if (!("DIGEST-MD5".equals(str)))
          break;
        localObject = DigestMD5SaslClient.getClient(paramString1, paramString2, paramString3, paramMap, paramCallbackHandler);
      }
      ++j;
    }
  }

  public String[] getMechanismNames(Map<String, ?> paramMap)
  {
    String[] arrayOfString = new String[2];
    arrayOfString[0] = "PLAIN";
    arrayOfString[1] = "DIGEST-MD5";
    return arrayOfString;
  }
}